package com.kaoshi.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.kaoshi.common.config.Result;
import com.kaoshi.entity.Jlb;
import com.kaoshi.service.IJlbService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author author
 * @since 2024-10-31
 */
@RestController
@CrossOrigin
@RequestMapping("/jlb")
public class JlbController {

    @Autowired
    private IJlbService jlbService;

    @RequestMapping("getInfo")
    public Result getInfo(Integer id){
        QueryWrapper<Jlb> jlbQueryWrapper = new QueryWrapper<>();
        QueryWrapper<Jlb> pid = jlbQueryWrapper.eq("pid", id);
        List<Jlb> list = jlbService.list(jlbQueryWrapper);
        return Result.ok(list);
    }

    @RequestMapping("update")
    public Result update(@RequestBody Jlb jlb){
        System.out.println(jlb);
        jlbService.updateById(jlb);
        return Result.ok();
    }


    @RequestMapping("deleteById/{id}")
    public Result deleteById(@PathVariable Integer id){
        jlbService.removeById(id);
        return Result.ok();
    }
}
